OPC Unified Architecture is designed as secure solution from the ground up. The result is a solid, secure infrastructure that can be, at the same time, complex to understand, and sometimes difficult to deploy and configure properly.
Security in OPC UA is a broad subject that we cannot and will not cover in detail here. It is recommended that you study available materials. Here are some useful links that can get you started:
QuickOPC-UA attempts to simplify the security configuration where possible, but a reasonable level of understanding OPC-UA security is still needed.
OPC UA supports mutual authentication of clients to servers, and servers to clients. In a secure OPC UA communication, the client and server applications must identify and authenticate themselves with the use of certificates. Depending on the communication method, OPC UA can also tie this mechanism to encryption and signing of the messages exchanged.
In addition to application security, in some scenarios it also plays a role who is the user of the application. Different user groups may be given different permissions to the application. See OPC UA User Authentication for information about how to provide the user information in your application.